home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / patch / patch1~1.zoo / diffs < prev    next >
Encoding:
Text File  |  1993-02-26  |  11.4 KB  |  498 lines

  1. *** /home/bammi/etc/src/patch/common.h    Tue Sep 29 16:45:36 1992
  2. --- common.h    Tue Sep 29 16:56:34 1992
  3. ***************
  4. *** 61,66 ****
  5. --- 61,67 ----
  6.   #define MAXHUNKSIZE 100000        /* is this enough lines? */
  7.   #define INITHUNKMAX 125            /* initial dynamic allocation size */
  8.   #define MAXLINELEN 1024
  9. + #ifndef atarist
  10.   #define BUFFERSIZE 1024
  11.   
  12.   #define SCCSPREFIX "s."
  13. ***************
  14. *** 70,75 ****
  15. --- 71,80 ----
  16.   #define RCSSUFFIX ",v"
  17.   #define CHECKOUT "co -l %s"
  18.   #define RCSDIFF "rcsdiff %s > /dev/null"
  19. + #else
  20. + extern unsigned long __DEFAULT_BUFSIZ__;
  21. + #define BUFFERSIZE __DEFAULT_BUFSIZ__
  22. + #endif
  23.   
  24.   #ifdef FLEXFILENAMES
  25.   #define ORIGEXT ".orig"
  26. ***************
  27. *** 97,103 ****
  28. --- 102,113 ----
  29.   
  30.   typedef char bool;
  31.   typedef long LINENUM;            /* must be signed */
  32. + #ifndef atarist
  33.   typedef unsigned MEM;            /* what to feed malloc */
  34. + #else
  35. + #include <stddef.h>
  36. + typedef size_t MEM;            /* what to feed malloc */
  37. + #endif
  38.   
  39.   /* globals */
  40.   
  41. ***************
  42. *** 109,115 ****
  43. --- 119,129 ----
  44.   EXT struct stat filestat;        /* file statistics area */
  45.   EXT int filemode INIT(0644);
  46.   
  47. + #ifndef atarist
  48.   EXT char buf[MAXLINELEN];        /* general purpose buffer */
  49. + #else
  50. + EXT char buf[32768];            /* general purpose buffer */
  51. + #endif
  52.   EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  53.   EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  54.   
  55. ***************
  56. *** 164,169 ****
  57. --- 178,186 ----
  58.   EXT char end_defined[128];        /* #endif xyzzy */
  59.   
  60.   EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  61. + #ifdef NODIR
  62. + EXT char *simple_backup_suffix INIT("~");
  63. + #endif
  64.   
  65.   #include <errno.h>
  66.   #ifndef errno
  67. ***************
  68. *** 170,175 ****
  69. --- 187,193 ----
  70.   extern int errno;
  71.   #endif
  72.   
  73. + #ifndef atarist
  74.   FILE *popen();
  75.   char *malloc();
  76.   char *realloc();
  77. ***************
  78. *** 180,185 ****
  79. --- 198,211 ----
  80.   char *rindex();
  81.   long lseek();
  82.   char *mktemp();
  83. + char *getenv();
  84. + #else
  85. + #include <string.h>
  86. + #include <memory.h>
  87. + #include <unistd.h>
  88. + EXT unsigned long __DEFAULT_BUFSIZ__ INIT(64*1024L);
  89. + #endif
  90.   #if 0                /* This can cause a prototype conflict.  */
  91.   #ifdef CHARSPRINTF
  92.   char *sprintf();
  93. ***************
  94. *** 187,193 ****
  95.   int sprintf();
  96.   #endif
  97.   #endif
  98.   #if !defined(S_ISDIR) && defined(S_IFDIR)
  99.   #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  100.   #endif
  101. --- 213,218 ----
  102. *** /home/bammi/etc/src/patch/inp.c    Tue Sep 29 16:45:36 1992
  103. --- inp.c    Tue Sep 29 17:04:48 1992
  104. ***************
  105. *** 90,95 ****
  106. --- 90,96 ----
  107.       statfailed = stat(filename, &filestat);
  108.       }
  109.       /* For nonexistent or read-only files, look for RCS or SCCS versions.  */
  110. + #ifndef atarist
  111.       if (statfailed
  112.       /* No one can write to it.  */
  113.       || (filestat.st_mode & 0222) == 0
  114. ***************
  115. *** 145,150 ****
  116. --- 146,155 ----
  117.           fatal3("can't check out file %s from %s\n", filename, cs);
  118.       }
  119.       }
  120. + #else
  121. +     if(statfailed)
  122. +         fatal2("Can't find %s.\n", filename);
  123. + #endif
  124.       filemode = filestat.st_mode;
  125.       if (!S_ISREG(filemode))
  126.       fatal2("%s is not a normal file--can't patch\n", filename);
  127. *** /home/bammi/etc/src/patch/patch.c    Tue Sep 29 16:45:36 1992
  128. --- patch.c    Tue Sep 29 16:50:06 1992
  129. ***************
  130. *** 138,143 ****
  131. --- 138,147 ----
  132.       int failtotal = 0;
  133.       int i;
  134.   
  135. + #ifdef atarist
  136. +     _binmode(1);
  137. +     stdin->_flag |= _IOBIN;    /* sorry! */
  138. + #endif
  139.       setbuf(stderr, serrbuf);
  140.       for (i = 0; i<MAXFILEC; i++)
  141.       filearg[i] = Nullch;
  142. ***************
  143. *** 151,156 ****
  144. --- 155,167 ----
  145.         int tmpname_len;
  146.   
  147.         tmpdir = getenv ("TMPDIR");
  148. + #ifdef atarist
  149. +       if (tmpdir == (char *)0) {
  150. +     tmpdir = getenv ("TEMP");
  151. +     if (tmpdir == (char *)0)
  152. +       tmpdir = getenv ("TMP");
  153. +       }
  154. + #endif
  155.         if (tmpdir == NULL) {
  156.       tmpdir = "/tmp";
  157.         }
  158. ***************
  159. *** 157,179 ****
  160. --- 168,222 ----
  161.         tmpname_len = strlen (tmpdir) + 20;
  162.   
  163.         TMPOUTNAME = (char *) malloc (tmpname_len);
  164. + #ifdef atarist
  165. +       strcpy (TMPOUTNAME, tmpdir);
  166. +       if (TMPOUTNAME[strlen (TMPOUTNAME) - 1] == '/' ||
  167. +       TMPOUTNAME[strlen (TMPOUTNAME) - 1] == '\\')
  168. +     TMPOUTNAME[strlen (TMPOUTNAME) - 1] = '\0';
  169. +       strcat (TMPOUTNAME, "/patoXXXX");
  170. + #else      
  171.         strcpy (TMPOUTNAME, tmpdir);
  172.         strcat (TMPOUTNAME, "/patchoXXXXXX");
  173. + #endif
  174.         Mktemp(TMPOUTNAME);
  175.   
  176.         TMPINNAME = (char *) malloc (tmpname_len);
  177. + #ifdef atarist
  178. +       strcpy (TMPINNAME, tmpdir);
  179. +       if (TMPINNAME[strlen (TMPINNAME) - 1] == '/' ||
  180. +       TMPINNAME[strlen (TMPINNAME) - 1] == '\\')
  181. +     TMPINNAME[strlen (TMPINNAME) - 1] = '\0';
  182. +       strcat (TMPINNAME, "/patiXXXX");
  183. + #else      
  184.         strcpy (TMPINNAME, tmpdir);
  185.         strcat (TMPINNAME, "/patchiXXXXXX");
  186. + #endif
  187.         Mktemp(TMPINNAME);
  188.   
  189.         TMPREJNAME = (char *) malloc (tmpname_len);
  190. + #ifdef atarist
  191. +       strcpy (TMPREJNAME, tmpdir);
  192. +       if (TMPREJNAME[strlen (TMPREJNAME) - 1] == '/' ||
  193. +       TMPREJNAME[strlen (TMPREJNAME) - 1] == '\\')
  194. +     TMPREJNAME[strlen (TMPREJNAME) - 1] = '\0';
  195. +       strcat (TMPREJNAME, "/patrXXXX");
  196. + #else      
  197.         strcpy (TMPREJNAME, tmpdir);
  198.         strcat (TMPREJNAME, "/patchrXXXXXX");
  199. + #endif
  200.         Mktemp(TMPREJNAME);
  201.   
  202.         TMPPATNAME = (char *) malloc (tmpname_len);
  203. + #ifdef atarist
  204. +       strcpy (TMPPATNAME, tmpdir);
  205. +       if (TMPPATNAME[strlen (TMPPATNAME) - 1] == '/' ||
  206. +       TMPPATNAME[strlen (TMPPATNAME) - 1] == '\\')
  207. +     TMPPATNAME[strlen (TMPPATNAME) - 1] = '\0';
  208. +       strcat (TMPPATNAME, "/patpXXXX");
  209. + #else      
  210.         strcpy (TMPPATNAME, tmpdir);
  211.         strcat (TMPPATNAME, "/patchpXXXXXX");
  212. + #endif
  213.         Mktemp(TMPPATNAME);
  214.       }
  215.   
  216. ***************
  217. *** 368,373 ****
  218. --- 411,441 ----
  219.       if (failed) {
  220.           failtotal += failed;
  221.           if (!*rejname) {
  222. + #ifdef atarist
  223. +         char *rindex();
  224. +         char *dot, *slash;
  225. +         Strcpy(rejname, outname);
  226. +         if ((slash = rindex(rejname, '\\')) ||
  227. +             (slash = rindex(rejname, '/')))
  228. +             slash++;
  229. +         else
  230. +             slash = rejname;
  231. +         if (dot = rindex(slash, '.')) {
  232. +             dot++;
  233. +             if (strlen(dot) >= 3)
  234. +                 Strcpy(&dot[2], REJEXT);
  235. +             else
  236. +                 Strcat(dot, REJEXT);
  237. +         } else {
  238. +             if (strlen(slash) > 8)
  239. +                 Strcpy(&slash[8], ".");
  240. +             else {
  241. +                     Strcat(slash, ".");
  242. +             }
  243. +             Strcat(slash, REJEXT);
  244. +         }
  245. + #else /* atarist */
  246.           Strcpy(rejname, outname);
  247.   #ifndef FLEXFILENAMES
  248.           {
  249. ***************
  250. *** 382,387 ****
  251. --- 450,456 ----
  252.           }
  253.   #endif
  254.           Strcat(rejname, REJEXT);
  255. + #endif /* !atarist */
  256.           }
  257.           if (skip_rest_of_patch) {
  258.           say4("%d out of %d hunks ignored--saving rejects to %s\n",
  259. *** /home/bammi/etc/src/patch/pch.c    Tue Sep 29 16:45:36 1992
  260. --- pch.c    Tue Sep 29 16:50:07 1992
  261. ***************
  262. *** 730,740 ****
  263. --- 730,743 ----
  264.   
  265.       if (diff_type == CONTEXT_DIFF &&
  266.         (fillcnt || (p_first > 1 && ptrn_copiable > 2*p_context)) ) {
  267. + #ifndef atarist    /* unfortunately this is always true for TOS because of
  268. +            the ^M at the end of a line -- just ignore warning */
  269.           if (verbose)
  270.           say4("%s\n%s\n%s\n",
  271.   "(Fascinating--this is really a new-style context diff but without",
  272.   "the telltale extra asterisks on the *** line that usually indicate",
  273.   "the new style...)");
  274. + #endif
  275.           diff_type = NEW_CONTEXT_DIFF;
  276.       }
  277.       
  278. ***************
  279. *** 1241,1246 ****
  280. --- 1244,1250 ----
  281.       return p_hunk_beg;
  282.   }
  283.   
  284. + #ifndef atarist
  285.   /* Apply an ed script by feeding ed itself. */
  286.   
  287.   void
  288. ***************
  289. *** 1303,1305 ****
  290. --- 1307,1317 ----
  291.       chmod(outname, filemode);
  292.       set_signals(1);
  293.   }
  294. + #else
  295. + void
  296. + do_ed_script()
  297. + {
  298. +     fprintf(stderr,"Sorry! TOS version of Patch cannot deal with ed scripts\n");
  299. +     exit(999);
  300. + }
  301. + #endif
  302. *** /home/bammi/etc/src/patch/util.c    Tue Sep 29 16:45:36 1992
  303. --- util.c    Tue Sep 29 17:30:29 1992
  304. ***************
  305. *** 48,54 ****
  306.       }
  307.   
  308.       if (origprae) {
  309. !     Strcpy(bakname, origprae);
  310.       Strcat(bakname, to);
  311.       } else {
  312.   #ifndef NODIR
  313. --- 48,54 ----
  314.       }
  315.   
  316.       if (origprae) {
  317. !         Strcpy(bakname, origprae);
  318.       Strcat(bakname, to);
  319.       } else {
  320.   #ifndef NODIR
  321. ***************
  322. *** 58,65 ****
  323.       Strcpy(bakname, backupname);
  324.       free(backupname);
  325.   #else /* NODIR */
  326.       Strcpy(bakname, to);
  327. !         Strcat(bakname, simple_backup_suffix);
  328.   #endif /* NODIR */
  329.       }
  330.   
  331. --- 58,91 ----
  332.       Strcpy(bakname, backupname);
  333.       free(backupname);
  334.   #else /* NODIR */
  335. + #ifdef atarist
  336. +     char *rindex();
  337. +     char *dot, *slash;
  338.       Strcpy(bakname, to);
  339. !     if ((slash = rindex(bakname, '\\')) ||
  340. !         (slash = rindex(bakname, '/')))
  341. !       slash++;
  342. !     else
  343. !       slash = bakname;
  344. !     if (dot = rindex(slash, '.')) {
  345. !       dot++;
  346. !       if (strlen(dot) >= 3)
  347. !         Strcpy(&dot[2], ORIGEXT);
  348. !       else
  349. !         Strcat(dot, ORIGEXT);
  350. !     } else {
  351. !       if (strlen(slash) > 8)
  352. !         Strcpy(&slash[8], ".");
  353. !       else {
  354. !         Strcat(slash, ".");
  355. !       }
  356. !       Strcat(slash, ORIGEXT);
  357. !     }
  358. ! #else /* atarist */
  359. !      Strcpy(bakname, to);
  360. !          Strcat(bakname, simple_backup_suffix);
  361. ! #endif /* !atarist */
  362.   #endif /* NODIR */
  363.       }
  364.   
  365. ***************
  366. *** 89,94 ****
  367. --- 115,123 ----
  368.       if (debug & 4)
  369.           say3("Moving %s to %s.\n", to, bakname);
  370.   #endif
  371. + #ifdef atarist
  372. +     copy_file(to, bakname);
  373. + #else
  374.       if (link(to, bakname) < 0) {
  375.           /* Maybe `to' is a symlink into a different file system.
  376.              Copying replaces the symlink with a file; using rename
  377. ***************
  378. *** 111,123 ****
  379. --- 140,159 ----
  380.           Close(tofd);
  381.           Close(bakfd);
  382.       }
  383. + #endif
  384.       while (unlink(to) >= 0) ;
  385.       }
  386.   #ifdef DEBUGGING
  387.       if (debug & 4)
  388.       say3("Moving %s to %s.\n", from, to);
  389.   #endif
  390. + #ifndef atarist
  391.       if (link(from, to) < 0) {        /* different file system? */
  392. + #else
  393. +     if (1) {
  394. + #endif
  395.       Reg4 int tofd;
  396.       
  397.       tofd = creat(to, 0666);
  398. ***************
  399. *** 253,258 ****
  400. --- 289,297 ----
  401.   
  402.       Sprintf(buf, pat, arg1, arg2, arg3);
  403.       Fflush(stderr);
  404. + #ifdef atarist
  405. +     r = _tos_ask(buf);
  406. + #else
  407.       write(2, buf, strlen(buf));
  408.       if (tty2) {                /* might be redirected to a file */
  409.       r = read(2, buf, sizeof buf);
  410. ***************
  411. *** 277,282 ****
  412. --- 316,322 ----
  413.       buf[0] = '\n';
  414.       r = 1;
  415.       }
  416. + #endif
  417.       if (r <= 0)
  418.       buf[0] = 0;
  419.       else
  420. ***************
  421. *** 429,434 ****
  422. --- 469,475 ----
  423.       free(fullname);
  424.   
  425.       if (stat(name, &filestat) && !assume_exists) {
  426. + #ifndef atarist
  427.       char *filebase = basename(name);
  428.       int pathlen = filebase - name;
  429.   
  430. ***************
  431. *** 442,447 ****
  432. --- 483,489 ----
  433.           || try("SCCS/%s%s", SCCSPREFIX, filebase)
  434.           || try(     "%s%s", SCCSPREFIX, filebase))
  435.         return name;
  436. + #endif
  437.       free(name);
  438.       name = Nullch;
  439.       }
  440. ***************
  441. *** 448,450 ****
  442. --- 490,538 ----
  443.   
  444.       return name;
  445.   }
  446. + #ifdef atarist
  447. + /* this kludge is necessary because stdin is most likely re-directed
  448. +    and there is no way to read from CON: due to the braindamage
  449. +    in handles -- thanks Atari
  450. +  */
  451. + #undef Fclose
  452. + #undef Fseek
  453. + #include <osbind.h>
  454. + int _tos_ask(buf)
  455. + char *buf;
  456. + {
  457. +     /* have to el-kludge it */
  458. +     int c;
  459. +     int r = 0;
  460. +     char *p = buf;
  461. +     write(2, buf, strlen(buf));
  462. +     while(( c = (Bconin(2) & 0x7f)) != '\r')
  463. +     {
  464. +     switch(c)
  465. +         {   /* we dont handle tabs/control chars nicely here */
  466. +         case 0:
  467. +         break;
  468. +         case '\b':
  469. +         case 0177:
  470. +         if(r > 0)
  471. +         { --p; --r; }
  472. +         Bconout(2, '\b'); Bconout(2, ' '); Bconout(2, '\b');
  473. +             break;
  474. +         default:
  475. +         if(c >= ' ')
  476. +         {
  477. +             *p++ = c; r++;
  478. +             Bconout(2, c);
  479. +         }
  480. +         /* else ignore control chars/tabs */
  481. +     }
  482. +     }
  483. +     Bconout(2, '\r');
  484. +     Bconout(2, '\n');
  485. +     *p++ = '\n'; *p = '\0';
  486. +     return r+1;
  487. + }
  488. + #endif
  489.